FROM ubuntu:23.04
 # 作者
LABEL u="何桥"
COPY ./app /
#配置 root 服务密钥
ENV ROOT_PASSWORD 123456
# 初始化脚本
RUN apt-get update -y && apt-get install -y openssh-server && \
    sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \
    sed -i 's/#UsePAM no/UsePAM no/' /etc/ssh/sshd_config && \
    sed -i 's/#Port 22/Port 22/' /etc/ssh/sshd_config && \
    echo "root:${ROOT_PASSWORD}" | chpasswd && \
    cat /sources.list > /etc/apt/sources.list && \
    ssh-keygen -t rsa -b 2048 -C "1813033378@qq.com" -N '' -f /root/.ssh/id_rsa && \
    cat /id_rsa.pub > /root/.ssh/authorized_keys && \
    rm -rf /sources.list /id_rsa.pub && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/* /var/lib/apt/archives/* && \
    chmod +x /*.sh

# 指定容器监听的端口
EXPOSE 22
# 启动脚本
ENTRYPOINT ["/start.sh"]